#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long int t, n;
	while(cin >> t)
	{
		while(t--)
		{
			cin >> n;
			long long int num = 0;
			while(n >= 2)
			{
				long long int c = floor((sqrt(1 + 24 * n) - 1) / 6);
				n -= ((3 * c + 1) * c) / 2;
				num++;
			}
			cout << num << endl;
		}
	}
	return 0;
}
